<template>
  <div>
    <nav-bar>
<!--      返回图标-->
      <div slot="left">
        <img src="~assets/img/common/back.svg" @click="back()"  class="back" alt="">

      </div>
<!--      功能模块-->
      <div slot="center" class="title">
        <div
          v-for="(item, index) in titles"
          @click="itemClick(index)"
          :class="{choose: currentIndex === index }"
          class="item">
          {{ item }}
        </div>

      </div>
    </nav-bar>
  </div>
</template>

<script>
//导入navbar
import NavBar from "../../../components/common/navbar/NavBar";

export default {
  name: "DetailNavBar",
  components: {NavBar},
  data(){
    return {
      titles: ['商品', '参数', '评论', '推荐'],
      currentIndex: 0
    }
  },
  methods:{
    itemClick(index){
      this.currentIndex = index
      //传出自定事件
      this.$emit('titleClick', index)
    },
    back(){
      this.$router.back()
    }
  }
}
</script>

<style scoped>

  .title{
    display: flex;
    font-size: 15px;
  }
  .item{
    flex: 1;
  }
  .choose{
    color: #ff5777;
  }
  .back{
    margin-top: 10px;
  }

</style>
